using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.CompilerServices;
using PickGold.Charting;
using PickGold.Charting.Utilities;

namespace PickGold.Charting.ChartTypes
{
	internal class StockChart : IChartType, IDisposable
	{
		protected bool forceCandleStick;
		protected StockOpenCloseMarkStyle openCloseStyle;

		public StockChart()
		{
		}

		public StockChart(StockOpenCloseMarkStyle style)
		{
			this.openCloseStyle = style;
		}

		public void AddSmartLabelMarkerPositions(CommonElements common, ChartArea area, Series series, ArrayList list)
		{
			bool flag = ChartHelper.IndexedSeries(common, area.GetSeriesFromChartType(this.Name).ToArray());
			Axis axis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
			Axis axis2 = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
			int num = 0;
			int num2 = 1;
			foreach (DataPoint point in series.Points)
			{
				double yValue = this.GetYValue(common, area, series, point, num2 - 1, 0);
				yValue = axis2.GetLogValue(yValue);
				if ((yValue > axis2.ViewMaximum) || (yValue < axis2.ViewMinimum))
				{
					num2++;
					continue;
				}
				double logValue = flag ? ((double)num2) : point.XValue;
				logValue = axis.GetLogValue(logValue);
				if ((logValue > axis.ViewMaximum) || (logValue < axis.ViewMinimum))
				{
					num2++;
					continue;
				}
				PointF empty = PointF.Empty;
				empty.Y = (float)axis2.GetLinearPosition(yValue);
				if (flag)
				{
					empty.X = (float)axis.GetPosition((double)num2);
				}
				else
				{
					empty.X = (float)axis.GetPosition(point.XValue);
				}
				string markerImage = point.MarkerImage;
				MarkerStyle markerStyle = point.MarkerStyle;
				SizeF size = SizeF.Empty;
				size.Width = point.MarkerSize;
				size.Height = point.MarkerSize;
				if (((common != null) && (common.graph != null)) && (common.graph.Graphics != null))
				{
					size.Width = (point.MarkerSize * common.graph.Graphics.DpiX) / 96f;
					size.Height = (point.MarkerSize * common.graph.Graphics.DpiY) / 96f;
				}
				if ((point.MarkerImage.Length > 0) && (common.graph != null))
				{
					common.ImageLoader.GetAdjustedImageSize(point.MarkerImage, common.graph.Graphics, ref size);
				}
				if (area.Area3DStyle.Enable3D)
				{
					float num5;
					float num6;
					area.GetSeriesZPositionAndDepth(series, out num5, out num6);
					Point3D[] points = new Point3D[] { new Point3D(empty.X, empty.Y, num6 + (num5 / 2f)) };
					area.matrix3D.TransformPoints(points);
					empty = points[0].PointF;
				}
				if ((markerStyle != MarkerStyle.None) || (markerImage.Length > 0))
				{
					if (num == 0)
					{
						size = common.graph.GetRelativeSize(size);
						RectangleF ef2 = new RectangleF(empty.X - (size.Width / 2f), empty.Y - size.Height, size.Width, size.Height);
						list.Add(ef2);
					}
					num++;
					if (series.MarkerStep == num)
					{
						num = 0;
					}
				}
				num2++;
			}
		}

		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
		}

		protected virtual void DrawLabel(CommonElements common, ChartArea area, ChartGraphics graph, Series ser, DataPoint point, PointF position, int pointIndex)
		{
			if ((ser.IsValueShownAsLabel || point.IsValueShownAsLabel) || (point.Label.Length > 0))
			{
				using (StringFormat format = new StringFormat())
				{
					string str;
					format.Alignment = StringAlignment.Near;
					format.LineAlignment = StringAlignment.Center;
					if (point.LabelAngle == 0)
					{
						format.Alignment = StringAlignment.Center;
						format.LineAlignment = StringAlignment.Far;
					}
					if (point.Label.Length == 0)
					{
						int index = 3;
						string strA = "";
						if (point.IsCustomPropertySet("LabelValueType"))
						{
							strA = point["LabelValueType"];
						}
						else if (ser.IsCustomPropertySet("LabelValueType"))
						{
							strA = ser["LabelValueType"];
						}
						if (string.Compare(strA, "High", StringComparison.OrdinalIgnoreCase) == 0)
						{
							index = 0;
						}
						else if (string.Compare(strA, "Low", StringComparison.OrdinalIgnoreCase) == 0)
						{
							index = 1;
						}
						else if (string.Compare(strA, "Open", StringComparison.OrdinalIgnoreCase) == 0)
						{
							index = 2;
						}
						str = ValueConverter.FormatValue(ser.Chart, point, point.Tag, point.YValues[index], point.LabelFormat, ser.YValueType, ChartElementType.DataPoint);
					}
					else
					{
						str = point.ReplaceKeywords(point.Label);
					}
					int labelAngle = point.LabelAngle;
					if (str.Trim().Length != 0)
					{
						SizeF empty = SizeF.Empty;
						if (ser.SmartLabelStyle.Enabled)
						{
							SizeF size = SizeF.Empty;
							size.Width = point.MarkerSize;
							size.Height = point.MarkerSize;
							if ((graph != null) && (graph.Graphics != null))
							{
								size.Width = (point.MarkerSize * graph.Graphics.DpiX) / 96f;
								size.Height = (point.MarkerSize * graph.Graphics.DpiY) / 96f;
							}
							if (point.MarkerImage.Length > 0)
							{
								common.ImageLoader.GetAdjustedImageSize(point.MarkerImage, graph.Graphics, ref size);
							}
							size = graph.GetRelativeSize(size);
							empty = graph.GetRelativeSize(graph.MeasureString(str, point.Font, new SizeF(1000f, 1000f), StringFormat.GenericTypographic));
							position = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, ser.SmartLabelStyle, position, empty, format, position, size, LabelAlignmentStyles.Top);
							labelAngle = 0;
						}
						if (!position.IsEmpty)
						{
							RectangleF backPosition = RectangleF.Empty;
							if ((!point.LabelBackColor.IsEmpty || (point.LabelBorderWidth > 0)) || !point.LabelBorderColor.IsEmpty)
							{
								if (empty.IsEmpty)
								{
									empty = graph.GetRelativeSize(graph.MeasureString(str, point.Font, new SizeF(1000f, 1000f), StringFormat.GenericTypographic));
								}
								position.Y -= empty.Height / 8f;
								SizeF ef4 = new SizeF(empty.Width, empty.Height);
								ef4.Height += empty.Height / 8f;
								ef4.Width += ef4.Width / ((float)str.Length);
								backPosition = PointChart.GetLabelPosition(graph, position, ef4, format, true);
							}
							using (Brush brush = new SolidBrush(point.LabelForeColor))
							{
								graph.DrawPointLabelStringRel(common, str, point.Font, brush, position, format, labelAngle, backPosition, point.LabelBackColor, point.LabelBorderColor, point.LabelBorderWidth, point.LabelBorderDashStyle, ser, point, pointIndex - 1);
							}
						}
					}
				}
			}
		}

		protected virtual void DrawOpenCloseMarks(ChartGraphics graph, ChartArea area, Series ser, DataPoint point, float xPosition, float width)
		{
			double logValue = this.VAxis.GetLogValue(point.YValues[2]);
			double axisValue = this.VAxis.GetLogValue(point.YValues[3]);
			if (((logValue > this.VAxis.ViewMaximum) || (logValue < this.VAxis.ViewMinimum)) && (axisValue <= this.VAxis.ViewMaximum))
			{
				double viewMinimum = this.VAxis.ViewMinimum;
			}
			float linearPosition = (float)this.VAxis.GetLinearPosition(logValue);
			float num4 = (float)this.VAxis.GetLinearPosition(axisValue);
			SizeF absoluteSize = graph.GetAbsoluteSize(new SizeF(width, width));
			float height = graph.GetRelativeSize(absoluteSize).Height;
			StockOpenCloseMarkStyle openCloseStyle = this.openCloseStyle;
			string strA = "";
			if (point.IsCustomPropertySet("OpenCloseStyle"))
			{
				strA = point["OpenCloseStyle"];
			}
			else if (ser.IsCustomPropertySet("OpenCloseStyle"))
			{
				strA = ser["OpenCloseStyle"];
			}
			if ((strA != null) && (strA.Length > 0))
			{
				if (string.Compare(strA, "Candlestick", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Candlestick;
				}
				else if (string.Compare(strA, "Triangle", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Triangle;
				}
				else if (string.Compare(strA, "Line", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Line;
				}
			}
			bool flag = true;
			bool flag2 = true;
			string str2 = "";
			if (point.IsCustomPropertySet("ShowOpenClose"))
			{
				str2 = point["ShowOpenClose"];
			}
			else if (ser.IsCustomPropertySet("ShowOpenClose"))
			{
				str2 = ser["ShowOpenClose"];
			}
			if ((str2 != null) && (str2.Length > 0))
			{
				if (string.Compare(str2, "Both", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = true;
					flag2 = true;
				}
				else if (string.Compare(str2, "Open", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = true;
					flag2 = false;
				}
				else if (string.Compare(str2, "Close", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = false;
					flag2 = true;
				}
			}
			bool flag3 = false;
			if (((openCloseStyle == StockOpenCloseMarkStyle.Candlestick) || ((xPosition - (width / 2f)) < area.PlotAreaPosition.X)) || ((xPosition + (width / 2f)) > area.PlotAreaPosition.Right))
			{
				graph.SetClip(area.PlotAreaPosition.ToRectangleF());
				flag3 = true;
			}
			if (this.forceCandleStick || (openCloseStyle == StockOpenCloseMarkStyle.Candlestick))
			{
				ColorConverter converter = new ColorConverter();
				Color color = point.Color;
				Color backSecondaryColor = point.BackSecondaryColor;
				string text = point["PriceUpColor"];
				if ((text != null) && (text.Length > 0))
				{
					bool flag4 = false;
					try
					{
						color = (Color)converter.ConvertFromString(text);
					}
					catch (ArgumentException)
					{
						flag4 = true;
					}
					catch (NotSupportedException)
					{
						flag4 = true;
					}
					if (flag4)
					{
						color = (Color)converter.ConvertFromInvariantString(text);
					}
				}
				text = point["PriceDownColor"];
				if ((text != null) && (text.Length > 0))
				{
					bool flag5 = false;
					try
					{
						backSecondaryColor = (Color)converter.ConvertFromString(text);
					}
					catch (ArgumentException)
					{
						flag5 = true;
					}
					catch (NotSupportedException)
					{
						flag5 = true;
					}
					if (flag5)
					{
						backSecondaryColor = (Color)converter.ConvertFromInvariantString(text);
					}
				}
				RectangleF empty = RectangleF.Empty;
				empty.Y = Math.Min(linearPosition, num4);
				empty.X = xPosition - (width / 2f);
				empty.Height = Math.Max(linearPosition, num4) - empty.Y;
				empty.Width = width;
				Color backColor = (linearPosition > num4) ? color : backSecondaryColor;
				Color borderColor = (point.BorderColor == Color.Empty) ? ((backColor == Color.Empty) ? point.Color : backColor) : point.BorderColor;
				SizeF size = new SizeF(empty.Height, empty.Height);
				if (graph.GetAbsoluteSize(size).Height > 1f)
				{
					graph.FillRectangleRel(empty, backColor, point.BackHatchStyle, point.BackImage, point.BackImageWrapMode, point.BackImageTransparentColor, point.BackImageAlignment, point.BackGradientStyle, point.BackSecondaryColor, borderColor, point.BorderWidth, point.BorderDashStyle, ser.ShadowColor, ser.ShadowOffset, PenAlignment.Inset);
				}
				else
				{
					graph.DrawLineRel(borderColor, point.BorderWidth, point.BorderDashStyle, new PointF(empty.X, empty.Y), new PointF(empty.Right, empty.Y), ser.ShadowColor, ser.ShadowOffset);
				}
			}
			else
			{
				if (openCloseStyle == StockOpenCloseMarkStyle.Triangle)
				{
					using (GraphicsPath path = new GraphicsPath())
					{
						PointF absolutePoint = graph.GetAbsolutePoint(new PointF(xPosition, linearPosition));
						PointF tf2 = graph.GetAbsolutePoint(new PointF(xPosition - (width / 2f), linearPosition + (height / 2f)));
						PointF tf3 = graph.GetAbsolutePoint(new PointF(xPosition - (width / 2f), linearPosition - (height / 2f)));
						using (Brush brush = new SolidBrush(point.Color))
						{
							if ((flag && (logValue <= this.VAxis.ViewMaximum)) && (logValue >= this.VAxis.ViewMinimum))
							{
								path.AddLine(tf2, absolutePoint);
								path.AddLine(absolutePoint, tf3);
								path.AddLine(tf3, tf3);
								graph.FillPath(brush, path);
							}
							if ((flag2 && (axisValue <= this.VAxis.ViewMaximum)) && (axisValue >= this.VAxis.ViewMinimum))
							{
								path.Reset();
								absolutePoint = graph.GetAbsolutePoint(new PointF(xPosition, num4));
								tf2 = graph.GetAbsolutePoint(new PointF(xPosition + (width / 2f), num4 + (height / 2f)));
								tf3 = graph.GetAbsolutePoint(new PointF(xPosition + (width / 2f), num4 - (height / 2f)));
								path.AddLine(tf2, absolutePoint);
								path.AddLine(absolutePoint, tf3);
								path.AddLine(tf3, tf3);
								graph.FillPath(brush, path);
							}
						}
						goto Label_068A;
					}
				}
				if ((flag && (logValue <= this.VAxis.ViewMaximum)) && (logValue >= this.VAxis.ViewMinimum))
				{
					graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, new PointF(xPosition - (width / 2f), linearPosition), new PointF(xPosition, linearPosition), ser.ShadowColor, ser.ShadowOffset);
				}
				if ((flag2 && (axisValue <= this.VAxis.ViewMaximum)) && (axisValue >= this.VAxis.ViewMinimum))
				{
					graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, new PointF(xPosition, num4), new PointF(xPosition + (width / 2f), num4), ser.ShadowColor, ser.ShadowOffset);
				}
			}
		Label_068A:
			if (flag3)
			{
				graph.ResetClip();
			}
		}

		protected virtual void DrawOpenCloseMarks3D(ChartGraphics graph, ChartArea area, Series ser, DataPoint point, float xPosition, float width, float zPosition, float depth)
		{
			double logValue = this.VAxis.GetLogValue(point.YValues[2]);
			double axisValue = this.VAxis.GetLogValue(point.YValues[3]);
			if (((logValue > this.VAxis.ViewMaximum) || (logValue < this.VAxis.ViewMinimum)) && (axisValue <= this.VAxis.ViewMaximum))
			{
				double viewMinimum = this.VAxis.ViewMinimum;
			}
			float linearPosition = (float)this.VAxis.GetLinearPosition(logValue);
			float num4 = (float)this.VAxis.GetLinearPosition(axisValue);
			SizeF absoluteSize = graph.GetAbsoluteSize(new SizeF(width, width));
			float height = graph.GetRelativeSize(absoluteSize).Height;
			StockOpenCloseMarkStyle openCloseStyle = this.openCloseStyle;
			string strA = "";
			if (point.IsCustomPropertySet("OpenCloseStyle"))
			{
				strA = point["OpenCloseStyle"];
			}
			else if (ser.IsCustomPropertySet("OpenCloseStyle"))
			{
				strA = ser["OpenCloseStyle"];
			}
			if ((strA != null) && (strA.Length > 0))
			{
				if (string.Compare(strA, "Candlestick", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Candlestick;
				}
				else if (string.Compare(strA, "Triangle", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Triangle;
				}
				else if (string.Compare(strA, "Line", StringComparison.OrdinalIgnoreCase) == 0)
				{
					openCloseStyle = StockOpenCloseMarkStyle.Line;
				}
			}
			bool flag = true;
			bool flag2 = true;
			string str2 = "";
			if (point.IsCustomPropertySet("ShowOpenClose"))
			{
				str2 = point["ShowOpenClose"];
			}
			else if (ser.IsCustomPropertySet("ShowOpenClose"))
			{
				str2 = ser["ShowOpenClose"];
			}
			if ((str2 != null) && (str2.Length > 0))
			{
				if (string.Compare(str2, "Both", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = true;
					flag2 = true;
				}
				else if (string.Compare(str2, "Open", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = true;
					flag2 = false;
				}
				else if (string.Compare(str2, "Close", StringComparison.OrdinalIgnoreCase) == 0)
				{
					flag = false;
					flag2 = true;
				}
			}
			bool flag3 = false;
			if (((xPosition - (width / 2f)) < area.PlotAreaPosition.X) || ((xPosition + (width / 2f)) > area.PlotAreaPosition.Right))
			{
				graph.SetClip(area.PlotAreaPosition.ToRectangleF());
				flag3 = true;
			}
			if (this.forceCandleStick || (openCloseStyle == StockOpenCloseMarkStyle.Candlestick))
			{
				ColorConverter converter = new ColorConverter();
				Color color = point.Color;
				Color backSecondaryColor = point.BackSecondaryColor;
				string text = point["PriceUpColor"];
				if ((text != null) && (text.Length > 0))
				{
					bool flag4 = false;
					try
					{
						color = (Color)converter.ConvertFromString(text);
					}
					catch (NotSupportedException)
					{
						flag4 = true;
					}
					catch (ArgumentException)
					{
						flag4 = true;
					}
					if (flag4)
					{
						color = (Color)converter.ConvertFromInvariantString(text);
					}
				}
				text = point["PriceDownColor"];
				if ((text != null) && (text.Length > 0))
				{
					bool flag5 = false;
					try
					{
						backSecondaryColor = (Color)converter.ConvertFromString(text);
					}
					catch (ArgumentException)
					{
						flag5 = true;
					}
					catch (NotSupportedException)
					{
						flag5 = true;
					}
					if (flag5)
					{
						backSecondaryColor = (Color)converter.ConvertFromInvariantString(text);
					}
				}
				RectangleF empty = RectangleF.Empty;
				empty.Y = Math.Min(linearPosition, num4);
				empty.X = xPosition - (width / 2f);
				empty.Height = Math.Max(linearPosition, num4) - empty.Y;
				empty.Width = width;
				Color backColor = (linearPosition > num4) ? color : backSecondaryColor;
				Color borderColor = (point.BorderColor == Color.Empty) ? ((backColor == Color.Empty) ? point.Color : backColor) : point.BorderColor;
				Point3D[] points = new Point3D[] { new Point3D(empty.X, empty.Y, zPosition + (depth / 2f)), new Point3D(empty.Right, empty.Bottom, zPosition + (depth / 2f)) };
				area.matrix3D.TransformPoints(points);
				empty.Location = points[0].PointF;
				empty.Width = Math.Abs((float)(points[1].X - points[0].X));
				empty.Height = Math.Abs((float)(points[1].Y - points[0].Y));
				if (empty.Height > 1f)
				{
					graph.FillRectangleRel(empty, backColor, point.BackHatchStyle, point.BackImage, point.BackImageWrapMode, point.BackImageTransparentColor, point.BackImageAlignment, point.BackGradientStyle, point.BackSecondaryColor, borderColor, point.BorderWidth, point.BorderDashStyle, ser.ShadowColor, ser.ShadowOffset, PenAlignment.Inset);
				}
				else
				{
					graph.DrawLineRel(borderColor, point.BorderWidth, point.BorderDashStyle, new PointF(empty.X, empty.Y), new PointF(empty.Right, empty.Y), ser.ShadowColor, ser.ShadowOffset);
				}
			}
			else
			{
				if (openCloseStyle == StockOpenCloseMarkStyle.Triangle)
				{
					using (GraphicsPath path = new GraphicsPath())
					{
						Point3D[] pointdArray2 = new Point3D[] { new Point3D(xPosition, linearPosition, zPosition + (depth / 2f)), new Point3D(xPosition - (width / 2f), linearPosition + (height / 2f), zPosition + (depth / 2f)), new Point3D(xPosition - (width / 2f), linearPosition - (height / 2f), zPosition + (depth / 2f)) };
						area.matrix3D.TransformPoints(pointdArray2);
						pointdArray2[0].PointF = graph.GetAbsolutePoint(pointdArray2[0].PointF);
						pointdArray2[1].PointF = graph.GetAbsolutePoint(pointdArray2[1].PointF);
						pointdArray2[2].PointF = graph.GetAbsolutePoint(pointdArray2[2].PointF);
						using (Brush brush = new SolidBrush(point.Color))
						{
							if ((flag && (logValue <= this.VAxis.ViewMaximum)) && (logValue >= this.VAxis.ViewMinimum))
							{
								path.AddLine(pointdArray2[1].PointF, pointdArray2[0].PointF);
								path.AddLine(pointdArray2[0].PointF, pointdArray2[2].PointF);
								path.AddLine(pointdArray2[2].PointF, pointdArray2[2].PointF);
								graph.FillPath(brush, path);
							}
							if ((flag2 && (axisValue <= this.VAxis.ViewMaximum)) && (axisValue >= this.VAxis.ViewMinimum))
							{
								pointdArray2[0] = new Point3D(xPosition, num4, zPosition + (depth / 2f));
								pointdArray2[1] = new Point3D(xPosition + (width / 2f), num4 + (height / 2f), zPosition + (depth / 2f));
								pointdArray2[2] = new Point3D(xPosition + (width / 2f), num4 - (height / 2f), zPosition + (depth / 2f));
								area.matrix3D.TransformPoints(pointdArray2);
								pointdArray2[0].PointF = graph.GetAbsolutePoint(pointdArray2[0].PointF);
								pointdArray2[1].PointF = graph.GetAbsolutePoint(pointdArray2[1].PointF);
								pointdArray2[2].PointF = graph.GetAbsolutePoint(pointdArray2[2].PointF);
								path.Reset();
								path.AddLine(pointdArray2[1].PointF, pointdArray2[0].PointF);
								path.AddLine(pointdArray2[0].PointF, pointdArray2[2].PointF);
								path.AddLine(pointdArray2[2].PointF, pointdArray2[2].PointF);
								graph.FillPath(brush, path);
							}
						}
						goto Label_08DB;
					}
				}
				if ((flag && (logValue <= this.VAxis.ViewMaximum)) && (logValue >= this.VAxis.ViewMinimum))
				{
					Point3D[] pointdArray3 = new Point3D[] { new Point3D(xPosition - (width / 2f), linearPosition, zPosition + (depth / 2f)), new Point3D(xPosition, linearPosition, zPosition + (depth / 2f)) };
					area.matrix3D.TransformPoints(pointdArray3);
					graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, pointdArray3[0].PointF, pointdArray3[1].PointF, ser.ShadowColor, ser.ShadowOffset);
				}
				if ((flag2 && (axisValue <= this.VAxis.ViewMaximum)) && (axisValue >= this.VAxis.ViewMinimum))
				{
					Point3D[] pointdArray4 = new Point3D[] { new Point3D(xPosition, num4, zPosition + (depth / 2f)), new Point3D(xPosition + (width / 2f), num4, zPosition + (depth / 2f)) };
					area.matrix3D.TransformPoints(pointdArray4);
					graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, pointdArray4[0].PointF, pointdArray4[1].PointF, ser.ShadowColor, ser.ShadowOffset);
				}
			}
		Label_08DB:
			if (flag3)
			{
				graph.ResetClip();
			}
		}

		public virtual Image GetImage(ChartTypeRegistry registry)
		{
			return (Image)registry.ResourceManager.GetObject(this.Name + "ChartType");
		}

		public virtual LegendImageStyle GetLegendImageStyle(Series series)
		{
			return LegendImageStyle.Line;
		}

		public virtual double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex)
		{
			return point.YValues[yValueIndex];
		}

		public virtual void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
		{
			this.ProcessChartType(false, graph, common, area, seriesToDraw);
		}

		protected virtual void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
		{
			if (area.Area3DStyle.Enable3D)
			{
				this.ProcessChartType3D(selection, graph, common, area, seriesToDraw);
			}
			else
			{
				bool flag = ChartHelper.IndexedSeries(common, area.GetSeriesFromChartType(this.Name).ToArray());
				foreach (Series series in common.DataManager.Series)
				{
					if (((string.Compare(series.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0) && (series.ChartArea == area.Name)) && series.IsVisible())
					{
						if (series.YValuesPerPoint < 4)
						{
							throw new ArgumentException(SR.ExceptionChartTypeRequiresYValues("StockChart", "4"));
						}
						this.HAxis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
						this.VAxis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
						double interval = flag ? 1.0 : area.GetPointsInterval(this.HAxis.IsLogarithmic, this.HAxis.logarithmBase);
						float width = (float)series.GetPointWidth(graph, this.HAxis, interval, 0.8);
						if (!selection)
						{
							common.Chart.CallOnPrePaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
						}
						int pointIndex = 1;
						foreach (DataPoint point in series.Points)
						{
							point.positionRel = new PointF(float.NaN, float.NaN);
							double xValue = point.XValue;
							if (flag)
							{
								xValue = pointIndex;
							}
							float position = (float)this.HAxis.GetPosition(xValue);
							double logValue = this.VAxis.GetLogValue(point.YValues[0]);
							double num7 = this.VAxis.GetLogValue(point.YValues[1]);
							xValue = this.HAxis.GetLogValue(xValue);
							if ((((xValue < this.HAxis.ViewMinimum) || (xValue > this.HAxis.ViewMaximum)) || ((logValue < this.VAxis.ViewMinimum) && (num7 < this.VAxis.ViewMinimum))) || ((logValue > this.VAxis.ViewMaximum) && (num7 > this.VAxis.ViewMaximum)))
							{
								pointIndex++;
								continue;
							}
							double axisValue = this.VAxis.GetLogValue(point.YValues[0]);
							double linearPosition = this.VAxis.GetLogValue(point.YValues[1]);
							if (axisValue > this.VAxis.ViewMaximum)
							{
								axisValue = this.VAxis.ViewMaximum;
							}
							if (axisValue < this.VAxis.ViewMinimum)
							{
								axisValue = this.VAxis.ViewMinimum;
							}
							axisValue = (float)this.VAxis.GetLinearPosition(axisValue);
							if (linearPosition > this.VAxis.ViewMaximum)
							{
								linearPosition = this.VAxis.ViewMaximum;
							}
							if (linearPosition < this.VAxis.ViewMinimum)
							{
								linearPosition = this.VAxis.ViewMinimum;
							}
							linearPosition = this.VAxis.GetLinearPosition(linearPosition);
							point.positionRel = new PointF(position, (float)axisValue);
							if (common.ProcessModePaint)
							{
								bool flag2 = false;
								if ((xValue == this.HAxis.ViewMinimum) || (xValue == this.HAxis.ViewMaximum))
								{
									graph.SetClip(area.PlotAreaPosition.ToRectangleF());
									flag2 = true;
								}
								graph.StartHotRegion(point);
								graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, new PointF(position, (float)axisValue), new PointF(position, (float)linearPosition), series.ShadowColor, series.ShadowOffset);
								this.DrawOpenCloseMarks(graph, area, series, point, position, width);
								graph.EndHotRegion();
								if (flag2)
								{
									graph.ResetClip();
								}
							}
							if (common.ProcessModeRegions)
							{
								RectangleF empty = RectangleF.Empty;
								empty.X = position - (width / 2f);
								empty.Y = (float)Math.Min(axisValue, linearPosition);
								empty.Width = width;
								empty.Height = ((float)Math.Max(axisValue, linearPosition)) - empty.Y;
								common.HotRegionsList.AddHotRegion(empty, point, series.Name, pointIndex - 1);
							}
							pointIndex++;
						}
						int num10 = 0;
						pointIndex = 1;
						foreach (DataPoint point2 in series.Points)
						{
							double num11 = point2.XValue;
							if (flag)
							{
								num11 = pointIndex;
							}
							float x = (float)this.HAxis.GetPosition(num11);
							double num13 = this.VAxis.GetLogValue(point2.YValues[0]);
							double num14 = this.VAxis.GetLogValue(point2.YValues[1]);
							num11 = this.HAxis.GetLogValue(num11);
							if ((((num11 < this.HAxis.ViewMinimum) || (num11 > this.HAxis.ViewMaximum)) || ((num13 < this.VAxis.ViewMinimum) && (num14 < this.VAxis.ViewMinimum))) || ((num13 > this.VAxis.ViewMaximum) && (num14 > this.VAxis.ViewMaximum)))
							{
								pointIndex++;
								continue;
							}
							double viewMaximum = this.VAxis.GetLogValue(point2.YValues[0]);
							double viewMinimum = this.VAxis.GetLogValue(point2.YValues[1]);
							if (viewMaximum > this.VAxis.ViewMaximum)
							{
								viewMaximum = this.VAxis.ViewMaximum;
							}
							if (viewMaximum < this.VAxis.ViewMinimum)
							{
								viewMaximum = this.VAxis.ViewMinimum;
							}
							viewMaximum = (float)this.VAxis.GetLinearPosition(viewMaximum);
							if (viewMinimum > this.VAxis.ViewMaximum)
							{
								viewMinimum = this.VAxis.ViewMaximum;
							}
							if (viewMinimum < this.VAxis.ViewMinimum)
							{
								viewMinimum = this.VAxis.ViewMinimum;
							}
							viewMinimum = this.VAxis.GetLinearPosition(viewMinimum);
							if ((point2.MarkerStyle != MarkerStyle.None) || (point2.MarkerImage.Length > 0))
							{
								SizeF size = SizeF.Empty;
								size.Width = point2.MarkerSize;
								size.Height = point2.MarkerSize;
								if ((graph != null) && (graph.Graphics != null))
								{
									size.Width = (point2.MarkerSize * graph.Graphics.DpiX) / 96f;
									size.Height = (point2.MarkerSize * graph.Graphics.DpiY) / 96f;
								}
								if (point2.MarkerImage.Length > 0)
								{
									common.ImageLoader.GetAdjustedImageSize(point2.MarkerImage, graph.Graphics, ref size);
								}
								PointF tf = PointF.Empty;
								tf.X = x;
								tf.Y = ((float)viewMaximum) - (graph.GetRelativeSize(size).Height / 2f);
								if (num10 == 0)
								{
									graph.DrawMarkerRel(tf, point2.MarkerStyle, (int)size.Height, (point2.MarkerColor == Color.Empty) ? point2.Color : point2.MarkerColor, (point2.MarkerBorderColor == Color.Empty) ? point2.BorderColor : point2.MarkerBorderColor, point2.MarkerBorderWidth, point2.MarkerImage, point2.MarkerImageTransparentColor, (point2.series != null) ? point2.series.ShadowOffset : 0, (point2.series != null) ? point2.series.ShadowColor : Color.Empty, new RectangleF(tf.X, tf.Y, size.Width, size.Height));
									if (common.ProcessModeRegions)
									{
										SizeF relativeSize = graph.GetRelativeSize(size);
										int insertIndex = common.HotRegionsList.FindInsertIndex();
										common.HotRegionsList.FindInsertIndex();
										if (point2.MarkerStyle == MarkerStyle.Circle)
										{
											float[] numArray = new float[] { tf.X, tf.Y, relativeSize.Width / 2f };
											common.HotRegionsList.AddHotRegion(insertIndex, graph, numArray[0], numArray[1], numArray[2], point2, series.Name, pointIndex - 1);
										}
										else
										{
											common.HotRegionsList.AddHotRegion(new RectangleF(tf.X - (relativeSize.Width / 2f), tf.Y - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height), point2, series.Name, pointIndex - 1);
										}
									}
								}
								num10++;
								if (series.MarkerStep == num10)
								{
									num10 = 0;
								}
							}
							this.DrawLabel(common, area, graph, series, point2, new PointF(x, (float)Math.Min(viewMaximum, viewMinimum)), pointIndex);
							pointIndex++;
						}
						if (!selection)
						{
							common.Chart.CallOnPostPaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
						}
					}
				}
			}
		}

		protected virtual void ProcessChartType3D(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
		{
			bool flag = ChartHelper.IndexedSeries(common, area.GetSeriesFromChartType(this.Name).ToArray());
			foreach (Series series in common.DataManager.Series)
			{
				if ((((string.Compare(series.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0) && (series.ChartArea == area.Name)) && series.IsVisible()) && ((seriesToDraw == null) || (seriesToDraw.Name == series.Name)))
				{
					float num3;
					float num4;
					if (series.YValuesPerPoint < 4)
					{
						throw new ArgumentException(SR.ExceptionChartTypeRequiresYValues("StockChart", "4"));
					}
					this.HAxis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
					this.VAxis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
					double interval = flag ? 1.0 : area.GetPointsInterval(this.HAxis.IsLogarithmic, this.HAxis.logarithmBase);
					float width = (float)series.GetPointWidth(graph, this.HAxis, interval, 0.8);
					if (!selection)
					{
						common.Chart.CallOnPrePaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
					}
					area.GetSeriesZPositionAndDepth(series, out num3, out num4);
					int pointIndex = 1;
					foreach (DataPoint point in series.Points)
					{
						point.positionRel = new PointF(float.NaN, float.NaN);
						double xValue = point.XValue;
						if (flag)
						{
							xValue = pointIndex;
						}
						float position = (float)this.HAxis.GetPosition(xValue);
						double logValue = this.VAxis.GetLogValue(point.YValues[0]);
						double num9 = this.VAxis.GetLogValue(point.YValues[1]);
						xValue = this.HAxis.GetLogValue(xValue);
						if ((((xValue < this.HAxis.ViewMinimum) || (xValue > this.HAxis.ViewMaximum)) || ((logValue < this.VAxis.ViewMinimum) && (num9 < this.VAxis.ViewMinimum))) || ((logValue > this.VAxis.ViewMaximum) && (num9 > this.VAxis.ViewMaximum)))
						{
							pointIndex++;
							continue;
						}
						bool flag2 = false;
						if ((xValue == this.HAxis.ViewMinimum) || (xValue == this.HAxis.ViewMaximum))
						{
							graph.SetClip(area.PlotAreaPosition.ToRectangleF());
							flag2 = true;
						}
						double axisValue = this.VAxis.GetLogValue(point.YValues[0]);
						double linearPosition = this.VAxis.GetLogValue(point.YValues[1]);
						if (axisValue > this.VAxis.ViewMaximum)
						{
							axisValue = this.VAxis.ViewMaximum;
						}
						if (axisValue < this.VAxis.ViewMinimum)
						{
							axisValue = this.VAxis.ViewMinimum;
						}
						axisValue = (float)this.VAxis.GetLinearPosition(axisValue);
						if (linearPosition > this.VAxis.ViewMaximum)
						{
							linearPosition = this.VAxis.ViewMaximum;
						}
						if (linearPosition < this.VAxis.ViewMinimum)
						{
							linearPosition = this.VAxis.ViewMinimum;
						}
						linearPosition = this.VAxis.GetLinearPosition(linearPosition);
						point.positionRel = new PointF(position, (float)axisValue);
						Point3D[] points = new Point3D[] { new Point3D(position, (float)axisValue, num4 + (num3 / 2f)), new Point3D(position, (float)linearPosition, num4 + (num3 / 2f)) };
						area.matrix3D.TransformPoints(points);
						graph.StartHotRegion(point);
						graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderDashStyle, points[0].PointF, points[1].PointF, series.ShadowColor, series.ShadowOffset);
						this.DrawOpenCloseMarks3D(graph, area, series, point, position, width, num4, num3);
						position = points[0].X;
						axisValue = points[0].Y;
						linearPosition = points[1].Y;
						graph.EndHotRegion();
						if (flag2)
						{
							graph.ResetClip();
						}
						if (common.ProcessModeRegions)
						{
							RectangleF empty = RectangleF.Empty;
							empty.X = position - (width / 2f);
							empty.Y = (float)Math.Min(axisValue, linearPosition);
							empty.Width = width;
							empty.Height = ((float)Math.Max(axisValue, linearPosition)) - empty.Y;
							common.HotRegionsList.AddHotRegion(empty, point, series.Name, pointIndex - 1);
						}
						pointIndex++;
					}
					int num12 = 0;
					pointIndex = 1;
					foreach (DataPoint point2 in series.Points)
					{
						double num13 = point2.XValue;
						if (flag)
						{
							num13 = pointIndex;
						}
						float x = (float)this.HAxis.GetPosition(num13);
						double num15 = this.VAxis.GetLogValue(point2.YValues[0]);
						double num16 = this.VAxis.GetLogValue(point2.YValues[1]);
						num13 = this.HAxis.GetLogValue(num13);
						if ((((num13 < this.HAxis.ViewMinimum) || (num13 > this.HAxis.ViewMaximum)) || ((num15 < this.VAxis.ViewMinimum) && (num16 < this.VAxis.ViewMinimum))) || ((num15 > this.VAxis.ViewMaximum) && (num16 > this.VAxis.ViewMaximum)))
						{
							pointIndex++;
							continue;
						}
						double y = this.VAxis.GetLogValue(point2.YValues[0]);
						double viewMaximum = this.VAxis.GetLogValue(point2.YValues[1]);
						if (y > this.VAxis.ViewMaximum)
						{
							y = this.VAxis.ViewMaximum;
						}
						if (y < this.VAxis.ViewMinimum)
						{
							y = this.VAxis.ViewMinimum;
						}
						y = (float)this.VAxis.GetLinearPosition(y);
						if (viewMaximum > this.VAxis.ViewMaximum)
						{
							viewMaximum = this.VAxis.ViewMaximum;
						}
						if (viewMaximum < this.VAxis.ViewMinimum)
						{
							viewMaximum = this.VAxis.ViewMinimum;
						}
						viewMaximum = this.VAxis.GetLinearPosition(viewMaximum);
						Point3D[] pointdArray2 = new Point3D[] { new Point3D(x, (float)y, num4 + (num3 / 2f)), new Point3D(x, (float)viewMaximum, num4 + (num3 / 2f)) };
						area.matrix3D.TransformPoints(pointdArray2);
						x = pointdArray2[0].X;
						y = pointdArray2[0].Y;
						viewMaximum = pointdArray2[1].Y;
						this.DrawLabel(common, area, graph, series, point2, new PointF(x, (float)Math.Min(y, viewMaximum)), pointIndex);
						if ((point2.MarkerStyle != MarkerStyle.None) || (point2.MarkerImage.Length > 0))
						{
							SizeF size = SizeF.Empty;
							size.Width = point2.MarkerSize;
							size.Height = point2.MarkerSize;
							if ((graph != null) && (graph.Graphics != null))
							{
								size.Width = (point2.MarkerSize * graph.Graphics.DpiX) / 96f;
								size.Height = (point2.MarkerSize * graph.Graphics.DpiY) / 96f;
							}
							if (point2.MarkerImage.Length > 0)
							{
								common.ImageLoader.GetAdjustedImageSize(point2.MarkerImage, graph.Graphics, ref size);
							}
							PointF tf = PointF.Empty;
							tf.X = x;
							tf.Y = ((float)y) - (graph.GetRelativeSize(size).Height / 2f);
							if (num12 == 0)
							{
								graph.DrawMarkerRel(tf, point2.MarkerStyle, (int)size.Height, (point2.MarkerColor == Color.Empty) ? point2.Color : point2.MarkerColor, (point2.MarkerBorderColor == Color.Empty) ? point2.BorderColor : point2.MarkerBorderColor, point2.MarkerBorderWidth, point2.MarkerImage, point2.MarkerImageTransparentColor, (point2.series != null) ? point2.series.ShadowOffset : 0, (point2.series != null) ? point2.series.ShadowColor : Color.Empty, new RectangleF(tf.X, tf.Y, size.Width, size.Height));
								if (common.ProcessModeRegions)
								{
									SizeF relativeSize = graph.GetRelativeSize(size);
									int insertIndex = common.HotRegionsList.FindInsertIndex();
									common.HotRegionsList.FindInsertIndex();
									if (point2.MarkerStyle == MarkerStyle.Circle)
									{
										float[] numArray = new float[] { tf.X, tf.Y, relativeSize.Width / 2f };
										common.HotRegionsList.AddHotRegion(insertIndex, graph, numArray[0], numArray[1], numArray[2], point2, series.Name, pointIndex - 1);
									}
									else
									{
										common.HotRegionsList.AddHotRegion(new RectangleF(tf.X - (relativeSize.Width / 2f), tf.Y - (relativeSize.Height / 2f), relativeSize.Width, relativeSize.Height), point2, series.Name, pointIndex - 1);
									}
								}
							}
							num12++;
							if (series.MarkerStep == num12)
							{
								num12 = 0;
							}
						}
						pointIndex++;
					}
					if (!selection)
					{
						common.Chart.CallOnPostPaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
					}
				}
			}
		}

		public virtual bool ApplyPaletteColorsToPoints
		{
			get
			{
				return false;
			}
		}

		public bool CircularChartArea
		{
			get
			{
				return false;
			}
		}

		public virtual bool DataPointsInLegend
		{
			get
			{
				return false;
			}
		}

		public virtual bool ExtraYValuesConnectedToYAxis
		{
			get
			{
				return true;
			}
		}

		internal Axis HAxis { set; get; }

		public virtual bool HundredPercent
		{
			get
			{
				return false;
			}
		}

		public virtual bool HundredPercentSupportNegative
		{
			get
			{
				return false;
			}
		}

		public virtual string Name
		{
			get
			{
				return "Stock";
			}
		}

		public virtual bool RequireAxes
		{
			get
			{
				return true;
			}
		}

		public bool SecondYScale
		{
			get
			{
				return false;
			}
		}

		public bool SideBySideSeries
		{
			get
			{
				return false;
			}
		}

		public virtual bool Stacked
		{
			get
			{
				return false;
			}
		}

		public bool StackSign
		{
			get
			{
				return false;
			}
		}

		public virtual bool SupportLogarithmicAxes
		{
			get
			{
				return true;
			}
		}

		public virtual bool SupportStackedGroups
		{
			get
			{
				return false;
			}
		}

		public virtual bool SwitchValueAxes
		{
			get
			{
				return false;
			}
		}

		internal Axis VAxis { set; get; }

		public virtual int YValuesPerPoint
		{
			get
			{
				return 4;
			}
		}

		public virtual bool ZeroCrossing
		{
			get
			{
				return false;
			}
		}
	}
}

